﻿<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <title>试卷预览</title>
    

    <!-- Le styles -->
 
    <link href="~/Scripts/NewFiles/bootstrap.min.css" rel="stylesheet" />

    <link href="~/Scripts/NewFiles/bootstrap-responsive.min.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" media="screen" href="~/css/smartadmin-skins.css">
<style>
body{font-family:"ff-tisa-web-pro-1","ff-tisa-web-pro-2","Lucida Grande","Helvetica Neue",Helvetica,Arial,"Hiragino Sans GB","Hiragino Sans GB W3","Microsoft YaHei UI","Microsoft YaHei","WenQuanYi Micro Hei",sans-serif;}
</style>
    
    <link href="~/Scripts/NewFiles/prettify.css" rel="stylesheet" />
    <link href="~/Scripts/NewFiles/docs.css" rel="stylesheet" />

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
    <![endif]-->

  </head>

  <body data-spy="scroll" data-target=".bs-docs-sidebar">

          <!--一个隐藏的input 保留CourseID--->

<!--一个隐藏分的input 保留PaperID-->
<input  id="praId" type="hidden" value="@ViewBag.pra.Id"/>


<header class=" subhead" id="overview" >
    <!--试卷的头部（包括试卷名，考试的科目，考核方式）-->
    <div id="TestPaperHeader"  style="margin-left:auto;margin-right:auto; float:left">
        <!--试卷标题-->
        <div class="container center " style="text-align:center;" >
           <label class="lead" >@ViewBag.pra.SPracticeName</label>
        </div>
        

        <!-- end 试卷标题-->


        

        <!--end 考试科目及考核方式-->

    </div>

    

</header>
<!-- end试卷的头部-->

  <div class="container" >

    <div class="row">
        <div class="span9">

               
        @{ 
                int libNo = 0;
                var i=0;
                string[] str = { "一、", "二、", "三、", "四、", "五、", "六、", "七、", "八、", "九、", "十、" };   //大题编号
                string[] type = { "", "单选题", "多选题", "判断题" };          
               }
            @foreach (var a in ViewBag.TestPaperDetail)
            {
                i++;
                var pid = "s" + i;
                var qNo = 0;     //大题里面小题题号
                var totalCount = a.StrategyItem.IScore;//大题的总分 
                var totalNum = a.StrategyItem.INum;//小题数量
                var perScore = totalCount / totalNum;//每小题的平均分
                <!--获取试题的大题信息-->
                <div id="@pid" style="margin-top:5px;">
                                  
                    <p class="font-md" >
                       <span style="font-size:20px;font-weight:bold;">@str[i-1] @type[a.StrategyItem.Id]
                           (总分：@ViewBag.score[i -1] | 每小题：@ViewBag.oneScore)
                       </span>
                    </p>
                    


                    @foreach (var b in a.LibItemList)//标题
                    {
                        qNo++;
                        string tempstr = qNo + ". ";
                        <!--小题题块-->
                        <div id="@b.LibItem.Id" style="margin-top:15px;">

                            <!--获取小题的题型  todo-->
                            <input type="hidden" id="TestLbId" value="@b.LibItem.IProblemType" />
                        <!--手动换题-->
                            <div style="float:right">       

                            </div>
                            <!--end 手动换题-->
                      <!--小题内容-->
                      <div style="">
                        <label class="font-md">
                           @tempstr @b.LibItem.STitle
                        </label>
                       @{
                            int libType = b.LibItem.IProblemType;
                            int tempI = 0;//用于标记选项
                            string[] Option = { "A.", "B.", "C.", "D.","E.","F.","G." };
                            string inType = libType == 2 ? "checkbox" : "radio";
                            libNo++;
                            string inName = "stuSel" + libNo;
                            
                             <table class="smart-form" >
                            
                            @foreach (var c in b.OptionList)
                            {
                                string OptionStr = "Option" + qNo;
                                int titleType = b.LibItem.IProblemType;
                              
                              <tr>
                                  <td ><input type="@inType" name="@inName" value="@c.Id : @b.LibItem.Id : @titleType"> </td>
                                  <td style="padding-left:10px;" class="font-md">@Option[tempI] @c.SOptionName</td>
                              </tr>
                                tempI++;
                            }
                                </table>
                        }
                       
                        
                          </div>
                            <!--end 小题内容-->

                            

                            </div>
                        <!-- end 小题题块-->
                    }

                </div> 
                <hr />
                <!--end 获取试题的大题信息--> 
            }
	         

      </div>
      <div class="span3 bs-docs-sidebar">
        <ul class="nav nav-list bs-docs-sidenav">
          <li><a href="#"><i class="icon-chevron-left"></i>题号</a></li>
            <input type="hidden" value="@libNo" id="libCount"/>
               @{ 
                var j=0;
                string[] strs = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" };   //大题编号
                           
               }

            @foreach (var a in ViewBag.TestPaperDetail)
            {
                j++;
                string Str="#s"+j;
               
                    <li><a href="@Str"><i class="icon-chevron-left"></i>@strs[j-1]</a></li>;
           
            
            }

        </ul>
      </div>
      
    </div>

  </div>

      <button class="btn btn-success" style="margin:5px 70px;" id="complete">提交</button>


    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    

        <script src="~/Scripts/jquery-1.8.2.min.js"></script>
        <script src="~/Scripts/NewFiles/bootstrap.min.js"></script>
        <script src="~/Scripts/NewFiles/holder.min.js"></script>
   <script src="~/Scripts/NewFiles/application.js"></script>

    <script src="~/Scripts/NewFiles/prettify.js"></script>

      <script>
          $(function () {
              var praId = $("#praId").val();
              var libCount = $("#libCount").val();
              $("#complete").click(function () {
                  if (confirm("不可重复提交，是否确定？") == true) {
                      var answer = "";
                      //得到每道题的答案
                      for (var i = 1; i <= libCount; i++) {

                          var inName = "input[name='stuSel" + i + "']:checked";
                          var sel = $(inName);//查找学生的选项
                          sel.each(function (i) {
                              answer = answer + "," + $(this).val();//拼装答案
                          });
                      }



                      if (answer == "") {
                          alert("请认真完成练习");
                          return false;
                      }
                      answer = dropRsplit(answer, ',')

                      $.ajax({
                          type: "POST",
                          url: "/Api/Student/CompletePractice",
                          data: { ans: answer, praId: praId }
                      }).done(function (data) {
                          if (data == 1) {

                              //跳转到查看页面
                              window.location.href = "/Student/PracticeResult?praId=" + praId;
                          }

                      })
                  }
              });
          })


          function dropRsplit(a, splitC) {
              var tmpA = a.split(splitC);
              var tmpObj = new Array();
              for (var i = 0; i < tmpA.length; i++) {
                  if (tmpA[i] != "") {
                      tmpObj.push(tmpA[i]);
                  }

              }
              return tmpObj.join(splitC);
          }
      </script>

  </body>
</html>
